// getPromise([rejectOrNot])
function getPromise(rejectOrNot) {
    var p;

    if (rejectOrNot === true) {
        p = new Promise(function(resolve, reject) {
            reject(new Error('reject'));
        });
    }
    else {
        p = new Promise(function(resolve, reject) {
            resolve(1);
        });
    }

    return p;
}
// getMyPromise([rejectOrNot])
function getMyPromise(rejectOrNot) {
    var p;

    if (rejectOrNot === true) {
        p = new MyPromise(function(resolve, reject) {
            reject(new Error('reject'));
        });
    }
    else {
        p = new MyPromise(function(resolve, reject) {
            resolve(1);
        });
    }

    return p;
}
// then的参数
function onFulfilled(future) {
console.log('log onFulfilled');
    console.log(future);
}
function onRejected(err) {
console.log('log onRejected');
    if (err instanceof Error) {
        console.log('[x]' + err.message);
    }
    else if (typeof err === 'string') {
        console.log('[x]err code: ' + err);
    }
    else {
        console.log('[x]', err);
    }
}